﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ContactList.Utils;
using PureMVC.Patterns;
using PureMVC.Interfaces;
using Telerik.Windows.Controls;

namespace ContactList
{
    public partial class MainPage : UserControl
    {
        #region Members

        private ApplicationFacade facade;
        private ContactServices.ContactServicesClient client;

        #endregion

        public MainPage()
        {
            InitializeComponent();

            // Start our PureMVC apparatus

            ////window.Owner = this.window;
            //mainWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            //mainWindow.Show();
            client = new ContactServices.ContactServicesClient();
            client.GetAllContactsCompleted += new EventHandler<ContactList.ContactServices.GetAllContactsCompletedEventArgs>(client_GetAllContactsCompleted);
            client.GetAllContactsAsync();
        }

        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            
        }

        void client_GetAllContactsCompleted(object sender, ContactList.ContactServices.GetAllContactsCompletedEventArgs e)
        {
            MessageBox.Show(e.ToString());
            dgContacts.ItemsSource = e.Result;
            client.CloseAsync();
        }

        //protected override void OnTransitionAnimationCompleted(EventArgs e)
        //{
        //    base.OnTransitionAnimationCompleted(e);

        //    window.Owner = this.window;
        //    window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
        //    window.Show();
        //}
    }
}
